<?php
/**
*管理员操作类
*@author :刘旭
**/

class class_admin extends core {
	/**
	*管理员登陆
	*@author：刘旭
	**/
	final static function log_in(){
		$admin=$_POST['admin'];
		$pwd=$_POST['pwd'];
		$name=trim($admin);
		$password=trim($pwd);
		$error=array();

		if(empty($admin))
		{
			$error['admin']="用户名不能为空！";
		}

		if(empty($pwd))
		{
			$error['pwd']="密码不能为空！";
		}
		
		//判断用户是否注册
		$user=core::selects('username,password',"user","id='1'");


		$pw=$user[0]->password;
		if($pwd!=$pw){
			$error["pwd"]="密码错误,请重新输入";
		}else{
			//成功登陆
			$_SESSION["admin"]=$admin;
			$_SESSION["admin_id"]=1;
		}
		
		if(!empty($error)){
			return $error;
		}
		
	}
}
?>